Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check dangerous modules instead of dangerous patterns #877

Merged
merged 7 commits into from
Mar 6, 2025

Conversation

albertvillanova
Copy link
Member

@albertvillanova albertvillanova commented Mar 4, 2025

Skip dangerous modules instead of dangerous patterns.

After this PR:

  • we support the inoffensive import of pandas.io
  • we no longer (info) log the skipping of dangerous attributes

EDIT:

  • We have also added an extra security check for dangerous functions
    • I added globals and locals to this list

Fix #663.
Supersede and close #664.

Copy link
Collaborator

@aymeric-roucher aymeric-roucher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the error could be made more explicit? For me "Forbidden return value: os") does not hint at why the import was refused. Maybe Forbidden import: osor somthing in that vein would be clearer?

@albertvillanova
Copy link
Member Author

I agree the error message should be improved: however the new security mechanism does not only check for imports (this was the cause of some previous vulnerabilities), but for any access to a module (as attribute, for example).

Something like: Forbidden access to module: os?

@albertvillanova
Copy link
Member Author

Also, I am trying to cover the missing dangerous functions previously listed in dangerous patterns.

@albertvillanova albertvillanova changed the title Skip dangerous modules instead of dangerous patterns Check dangerous modules instead of dangerous patterns Mar 6, 2025
@albertvillanova albertvillanova merged commit df2b7eb into huggingface:main Mar 6, 2025
3 checks passed
@albertvillanova
Copy link
Member Author

Added an extra security check for dangerous functions, besides dangerous modules

  • I added globals and locals to this list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Skipping dangerous attribute" check
2 participants